package ru.vboxdc.service;

import com.ibatis.common.resources.Resources;
import com.ibatis.sqlmap.client.SqlMapClientBuilder;
import com.ibatis.sqlmap.client.SqlMapClient;

import java.io.Reader;
import java.io.IOException;

/**
 * User: lelon
 * Date: 08.02.2009
 * Time: 23:46:07
 */
public class SqlMapper {

    private static SqlMapClient sqlMapper;

    static {
    try {
      Reader reader = Resources.getResourceAsReader("SqlMapConfig.xml");
      sqlMapper = SqlMapClientBuilder.buildSqlMapClient(reader);
      reader.close();
    } catch (IOException e) {
      // Fail fast.
      throw new RuntimeException("Something bad happened while building the SqlMapClient instance." + e, e);
    }
  }

    public static SqlMapClient get() {
        return sqlMapper;
    }
}
